package com.itheima.chapter10.theadPool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
//ThreadPoolExecutor 创建线程池对象

public class Demo3 {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor =new ThreadPoolExecutor(2,5,3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());

        threadPoolExecutor.submit(new RunnableImpl());
        threadPoolExecutor.submit(new RunnableImpl());
        threadPoolExecutor.submit(new RunnableImpl());
        threadPoolExecutor.submit(()->{
            System.out.println(Thread.currentThread().getName()+"**执行");

        });
        threadPoolExecutor.shutdown();

    }
}
